/*
 * HemisphericLight.cpp
 *
 *  Created on: 17/06/2013
 *      Author: gabriel
 */

#include "HemisphericLight.h"

HemisphericLight::HemisphericLight() {

	for(int i = 0; i<4; i++){
		skyColour[i] = 1.0f;
		groundColour[i] = 1.0f;
		position[i] = 0.0f;
	}

}

HemisphericLight::~HemisphericLight() {
}


void HemisphericLight::setMatrix(Matrix4f &mat){
	this->matrix.copy(mat);
}

void HemisphericLight::setup(){

	glUseProgram(program->programHandle);

	int lightSkyUniformHandle = program->getUniformHandle("Sky_Colour");
	int lightGroundUniformHandle = program->getUniformHandle("Ground_Colour");

	glUniform4fv(lightSkyUniformHandle, 1, skyColour);
	glUniform4fv(lightGroundUniformHandle, 1, groundColour);
}

void HemisphericLight::setShader(Shader *program){
	this->program = program;
}


void HemisphericLight::setColour(float skyColour[4], float groundColour[4]){

	for(int i =0; i<4;i++){
		this->skyColour[i] = skyColour[i];
		this->groundColour[i] = groundColour[i];

	}

	setup();

}


void HemisphericLight::enable(){

	matrix.transformVec4f(position);
	int lightposUniformHandle = program->getUniformHandle("Light_Position");
	glUniform4fv(lightposUniformHandle, 1, position);
}


void HemisphericLight::setPosition(float x, float y, float z, float w){

	position[0] = x;
	position[1] = y;
	position[2] = z;
	position[3] = w;
}



